﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectBrandTree.aspx.cs" Inherits="Besture.UI.Admin.Common.SelectBrandTree" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/Admin/PlugIn/ZTree/css/zTreeStyle/zTreeStyle.css" type="text/css"  />
    <script type="text/javascript" src="/Admin/PlugIn/ZTree/js/jquery-1.4.4.min.js" ></script>
    <script type="text/javascript" src="/Admin/PlugIn/ZTree/js/jquery.ztree.core-3.5.js" ></script>
    <script type="text/javascript" src="/Admin/PlugIn/ZTree/js/jquery.ztree.excheck-3.5.js"  ></script>
    <script type="text/javascript">
		<!--
        var setting = {
			data: {
				simpleData: {
					enable: true
				}
			}
		};
        var zNodes = <%=_json %>;

        $(document).ready(function () {
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });
		//-->
        
    	var api = frameElement.api, W = api.opener;

    	api.button({
    	    id: 'valueOk',
    	    name: '确定',
    	    callback:ok
    	});

    	
        //选中默认节点
        function DefaultSelectNodes() {
            var classID = "<%=_ClassID %>";
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var node = treeObj.getNodeByParam("id",classID,null);
            treeObj.selectNode(node);
        }

    	function ok() {
    	   var zTree = $.fn.zTree.getZTreeObj("treeDemo");
 
            var nodes = zTree.getSelectedNodes(true);
            //选中值
            var selectClassID = "";
            //选中名称
    	    var selectClassName = "";
    	    
            for (var i = 0; i < nodes.length; i++) {
                selectClassID = nodes[i].id;
                selectClassName = nodes[i].name;
                if (nodes[i].level==0) {
                    return false;
                }
                break;
            }          
    	    W.jQuery(".SelectProductClass_SelectClassID").val(selectClassID);
    	    W.jQuery("#SelectProductClass_Select").val(selectClassName);
    	}

    	$(function() {
    	    DefaultSelectNodes();
    	});

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="content_wrap">
        <div class="zTreeDemoBackground left">
            <ul id="treeDemo" class="ztree">
            </ul>
        </div>
    </div>
    </form>
</body>
</html>
